Copy data and free data with free().
authorAlexander Larsson <alexl@redhat.com>
Mon, 19 Feb 2001 14:35:25 +0000 (14:35 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 19 Feb 2001 14:35:25 +0000 (14:35 +0000)
2001-02-19 Alexander Larsson  <alexl@redhat.com>

* gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
Copy data and free data with free().

* gdk-pixbuf/gdk-pixbuf.c:
* gdk-pixbuf/io-jpeg.c:
* gdk-pixbuf/io-png.c:
Use g_try_malloc/g_free instead malloc/free.

* gdk-pixbuf/test-gdk-pixbuf.c:
Must... initialize... gobject...

* gdk-pixbuf/pixops/timescale.c:
* gtk/gtkcalendar.c:
Use g_malloc instead of malloc.

14 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk-pixbuf/gdk-pixbuf.c
gdk-pixbuf/io-jpeg.c
gdk-pixbuf/io-png.c
gdk-pixbuf/pixops/timescale.c
gdk-pixbuf/test-gdk-pixbuf.c
gdk/linux-fb/gdkimage-fb.c
gtk/gtkcalendar.c

index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 3429a42d1b4a8ad44f1ee62112a129d4dbd75e81..d4d0e89ed10b087838b9eb77966988fdb55eec40 100644 (file)
@@ -1,4 +1,21 @@
-2001-02-19    <alla@lysator.liu.se>
+2001-02-19 Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/linux-fb/gdkimage-fb.c (gdk_image_new_bitmap):
+       Copy data and free data with free().
+
+       * gdk-pixbuf/gdk-pixbuf.c:
+       * gdk-pixbuf/io-jpeg.c:
+       * gdk-pixbuf/io-png.c:
+       Use g_try_malloc/g_free instead malloc/free.
+       
+       * gdk-pixbuf/test-gdk-pixbuf.c:
+       Must... initialize... gobject...
+       
+       * gdk-pixbuf/pixops/timescale.c:
+       * gtk/gtkcalendar.c:
+       Use g_malloc instead of malloc.
+       
+2001-02-19 Alexander Larsson  <alla@lysator.liu.se>
 
        * gtk/testgtkrc:
        Comment out property assignments, these don't work yet.
index 724753d2da10c1bc074a0773c5b82cf2e451bed0..2a65082d939d19a8bf3384e874a834308b04c6ed 100644 (file)
@@ -117,7 +117,7 @@ gdk_pixbuf_unref (GdkPixbuf *pixbuf)
 static void
 free_buffer (guchar *pixels, gpointer data)
 {
-       free (pixels);
+       g_free (pixels);
 }
 
 /**
@@ -153,7 +153,7 @@ gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sampl
        channels = has_alpha ? 4 : 3;
        rowstride = 4 * ((channels * width + 3) / 4);
 
-       buf = malloc (height * rowstride);
+       buf = g_try_malloc (height * rowstride);
        if (!buf)
                return NULL;
 
@@ -188,7 +188,7 @@ gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
        size = ((pixbuf->height - 1) * pixbuf->rowstride +
                pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
 
-       buf = malloc (size * sizeof (guchar));
+       buf = g_try_malloc (size * sizeof (guchar));
        if (!buf)
                return NULL;
 
index de40d2e786232027850c7619fab2b9d2ea2908d1..2c295131d98a7af916d39f13e345a5ca6f679f93 100644 (file)
@@ -145,7 +145,7 @@ output_message_handler (j_common_ptr cinfo)
 static void
 free_buffer (guchar *pixels, gpointer data)
 {
-       free (pixels);
+       g_free (pixels);
 }
 
 
@@ -222,7 +222,7 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error)
        w = cinfo.output_width;
        h = cinfo.output_height;
 
-       pixels = malloc (h * w * 3);
+       pixels = g_try_malloc (h * w * 3);
        if (!pixels) {
                jpeg_destroy_decompress (&cinfo);
 
index 19ca6132bee1c92129d6f33a941d98c1106bf21b..9ece35d40dfae9f55bbd1df0a1e3444016c271e5 100644 (file)
@@ -176,7 +176,7 @@ png_simple_warning_callback(png_structp png_save_ptr,
 static void
 free_buffer (guchar *pixels, gpointer data)
 {
-       free (pixels);
+       g_free (pixels);
 }
 
 /* Shared library entry point */
@@ -230,7 +230,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
        else
                bpp = 3;
 
-       pixels = malloc (w * h * bpp);
+       pixels = g_try_malloc (w * h * bpp);
        if (!pixels) {
                 /* Check error NULL, normally this would be broken,
                  * but libpng makes me want to code defensively.
@@ -701,7 +701,7 @@ gdk_pixbuf__png_image_save (FILE          *f,
                png_set_IHDR (png_ptr, info_ptr, w, h, bpc,
                              PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
                              PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-               data = malloc (w * 3 * sizeof (char));
+               data = g_try_malloc (w * 3 * sizeof (char));
 
                if (data == NULL) {
                        /* Check error NULL, normally this would be broken,
@@ -741,7 +741,7 @@ gdk_pixbuf__png_image_save (FILE          *f,
        }
 
        if (data)
-               free (data);
+               g_free (data);
 
        png_write_end (png_ptr, info_ptr);
        png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
index f3c9045667028851199bd43e14907c1399e0b711..76b2f8d19d26dd8a2b8ce8a97cf7c493f709cf4a 100644 (file)
@@ -146,10 +146,10 @@ int main (int argc, char **argv)
 
        int filter_level;
 
-       src_buf = malloc(src_rowstride * src_height);
+       src_buf = g_malloc(src_rowstride * src_height);
        memset (src_buf, 0x80, src_rowstride * src_height);
        
-       dest_buf = malloc(dest_rowstride * dest_height);
+       dest_buf = g_malloc(dest_rowstride * dest_height);
        memset (dest_buf, 0x80, dest_rowstride * dest_height);
 
        for (filter_level = GDK_INTERP_NEAREST ; filter_level <= GDK_INTERP_HYPER; filter_level++)
@@ -216,8 +216,8 @@ int main (int argc, char **argv)
          }
        printf ("\n");
 
-       free (src_buf);
-       free (dest_buf);
+       g_free (src_buf);
+       g_free (dest_buf);
       }
 
   printf ("SCALE\n=====\n\n");
index 4f6f51cc5b057eb8fe9318eaee8de7df8ea5a0c5..c2bfbbbf02bf8daad508073a1f9806059c17bd06 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdlib.h>
 #include "gdk-pixbuf.h"
+#include <gobject/gtype.h>
 
 \f
 
@@ -228,6 +229,8 @@ main (int argc, char **argv)
        int result;
 
        result = EXIT_SUCCESS;
+
+       g_type_init (G_TYPE_DEBUG_NONE);
        
        /* Run some tests. */
        if (!simple_composite_test ()) {
index 26aded2a243b0b7a6fd79d2680784abe86f40776..851c8bbd373e9cdf007cc3329e359b65e58e821e 100644 (file)
@@ -126,7 +126,12 @@ gdk_image_new_bitmap(GdkVisual *visual,
   image->bpp = 1;
   image->bpl = (w+7)/8;
   image->mem = g_malloc (image->bpl * h / 8);
+  memcpy (image->mem, data, image->bpl * h / 8);
 
+  /* This must be freed using free, not g_free, since in the X version
+     this is freed by xlib. */
+  free (data); 
+  
   return image;
 }
 
index d9ae77af12a2c0476901d6385f720210b6a098c9..debb603e37aa286a9d7567da1197d36e0b1b19d3 100644 (file)
@@ -430,7 +430,7 @@ gtk_calendar_init (GtkCalendar *calendar)
   widget = GTK_WIDGET (calendar);
   GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
   
-  calendar->private_data = (gpointer) malloc (sizeof (GtkCalendarPrivateData));
+  calendar->private_data = (gpointer) g_malloc (sizeof (GtkCalendarPrivateData));
   private_data = GTK_CALENDAR_PRIVATE_DATA (calendar);
 
   if (!default_abbreviated_dayname[0])